<script>
import outMain from "@/components/outMain.vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { Accreditation } from "@/http/api";

export default {
  components: { outMain },
  name: "",
  data() {
    return {
      tableData: [],
      statusArr: [
        { label: "全部", value: "" },
        { label: "正常", value: "1" },
        { label: "到期", value: "2" },
      ],
      queryData: {
        statusValue: "",
        search: "",
        page: 1,
        per_page: 10,
      },
      total: 0,
    };
  },
  props: {},
  setup() {},
  methods: {
    addFn(id) {
      this.$router.push({
        path: "/accountObtaiAdd",
        query: {
          id: id,
          page: id ? this.queryData.page : undefined,
        },
      });
    },
    getData() {
      Accreditation(this.queryData).then((res) => {
        if (res.data.code == 1) {
          this.tableData = res.data.data.data;
          this.total = res.data.data.total;
        }
      });
    },
  },
  mounted() {},
  created() {
    this.queryData.page = Number(localStorage.getItem("boot_page")) || 1;

    this.getData();
  },
};
</script>
<template>
  <outMain>
    <div class="tableCont">
      <div class="tableName flexCont">
        <div>办证账号列表（{{ total }}）</div>
      </div>
      <div class="tableSerch">
        <div class="serchLeft">
          <btn
            value="新增"
            style="margin-bottom: 15px"
            v-if="total == 0"
            @ok="addFn"
          ></btn>
        </div>
      </div>
      <el-table class="tableMain" :data="tableData" stripe style="width: 100%">
        <el-table-column
          prop="accreditation_person"
          show-overflow-tooltip
          label="负责人"
        />
        <el-table-column
          prop="accreditation_mobile"
          show-overflow-tooltip
          label="手机号"
        />
        <el-table-column show-overflow-tooltip label="账号状态">
          <template #default="{ row }">
            <div class="tagGroup">
              <el-tag v-if="row.accreditation_status == 1">正常</el-tag>
              <el-tag type="info" v-if="row.accreditation_status == 2"
                >已到期</el-tag
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="create_time"
          show-overflow-tooltip
          label="创建时间"
          width="180"
        />

        <el-table-column
          prop="lastlogin_time"
          show-overflow-tooltip
          width="180"
          label="最近登录时间"
        />
        <el-table-column
          prop="expiration_time"
          show-overflow-tooltip
          label="到期时间"
        />
        <el-table-column prop="Name" width="100" label="操作">
          <template #default="{ row }">
            <div class="tableCtrl">
              <div
                class="blueText ctrlText"
                @click="addFn(row.accreditation_id)"
              >
                编辑
              </div>
              <div class="blueText ctrlText">加时</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pageCont">
        <el-pagination
          v-model:currentPage="queryData.page"
          v-model:page-size="queryData.per_page"
          background
          layout="total, prev, pager, next, jumper"
          :total="total"
          @size-change="getData"
          @current-change="getData"
        />
      </div>
    </div>
  </outMain>
</template>
<style scoped lang="less"></style>
